package edu.uoc.tdp.client.gestors;

import java.awt.Component;

import javax.swing.ImageIcon;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

@SuppressWarnings("serial")
public class RenderTaula extends DefaultTableCellRenderer
{
   public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
      boolean hasFocus, int row, int column)
   {
	  String icona = "";
	  ImageIcon icon = null;
	   
	  super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column);
      String valor = (String)value;
      
      if (valor == "Assistit"){
       icona = "/IconaOkVerd.png";
      }
      else if (valor == "Inscrit"){
    	  icona = "/iconaExclamacio.jpg";	  
      }
      else if (valor == "Confirmat"){
       icona = "/iconaOk.png";
      }
      else{
    	  this.setIcon(null);
          return this;    	  
      }
 
      java.net.URL imgURL = getClass().getResource(icona);	
      if (imgURL != null) {
		  icon = new ImageIcon(imgURL); 
	  }
	  this.setText("");
	  this.setIcon(icon);
      return this;
   }  
}